package com.xidian.zhiancloud.service.riskcontrol.riskidenva;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.riskcontrol.riskidenva.TRiskProcessInspectionItemMapper;
import com.xidian.zhiancloud.model.riskcontrol.TRiskProcessInspectionItemList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 工艺节点-检查项
 */
@Service
public class TRiskProcessInspectionItemService extends ServiceImpl
        <TRiskProcessInspectionItemMapper, TRiskProcessInspectionItemList> {

    @Autowired
    TRiskProcessInspectionItemMapper tRiskProcessInspectionItemMapper;

    //风险辨识-风险辨识-工艺节点-检查项-添加
    public int insertProcessInspectionItem(TRiskProcessInspectionItemList proInspeItems){
        return tRiskProcessInspectionItemMapper.insertProcessInspectionItem
                (proInspeItems);
    }

    //风险辨识-风险辨识-工艺节点-检查项-编辑
    public int updateProcessInspectionItem(String id,
           TRiskProcessInspectionItemList proInspeItems){
        return tRiskProcessInspectionItemMapper.updateProcessInspectionItem
                (Long.valueOf(id),proInspeItems);
    }

    //风险辨识-风险辨识-删除检查项
    public int deleteProcessInspectionItem(String id){
        List<String> lists = getList(id);
        return tRiskProcessInspectionItemMapper.deleteProcessInspectionItem(lists);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }

    public List<TRiskProcessInspectionItemList> getByIds(Long companyId, String taskAllocatId){
        return tRiskProcessInspectionItemMapper.getByIds(companyId,taskAllocatId);
    }
    
}
